﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using YArchitech.Controls;
using YArchitech.LIB;
using YArchitech.Revit;
using YJKRGeometry;
using QuickModel.CommonTrans;
using QuickModel.Forms;
using QuickModel.InteractiveOperation;
using Transfer.Utils;

namespace QuickModel.DuctFastModel
{
	internal class DuctRequestMaker : InteractiveOperationBase
	{
		public DuctRequestMaker(ExternalCommandData useExternalCommandData) : base(useExternalCommandData)
		{
			this.m_uiDoc = useExternalCommandData.Application.ActiveUIDocument;
		}

		public override bool IfBreak
		{
			get
			{
				throw new NotImplementedException();
			}
		}

		public double MaxDuctWidth
		{
			get
			{
				return this.m_MaxDuctWidth;
			}
			set
			{
				this.m_MaxDuctWidth = value;
			}
		}

		public override void PrepareRequest()
		{
			Document document = this.m_uiDoc.Document;
			List<ViewType> list = new List<ViewType>();
			list.Add(1);
			list.Add(2);
			bool flag = !YJKRevitTools.ViewCheck(this.m_uiDoc, list);
			if (flag)
			{
				this.m_bCancel = true;
			}
			else
			{
				DuctFastModelForm ductFastModelForm = new DuctFastModelForm();
				DialogResult dialogResult;
				while ((dialogResult = ductFastModelForm.ShowDialog(this.m_handleRevit)) == DialogResult.OK)
				{
					bool flag2 = ductFastModelForm.DlgCloseType == CloseDuctDlgType.SelectDuctLine;
					if (flag2)
					{
						bool flag3 = this.tmpCategory != null;
						if (flag3)
						{
							this.ShowLayer(document, ref this.tmpCategory);
						}
						try
						{
							DwgEntitiesSelection dwgEntitiesSelection = new DwgEntitiesSelection(this.m_uiDoc);
							Transaction transaction = new Transaction(document);
							try
							{
								transaction.Start("选择风管边线");
								dwgEntitiesSelection.TryPickSameLayerCurve(out this.lstCurveInfoArc, true, SelecteEntType.eLine | SelecteEntType.eArc | SelecteEntType.ePolyLine, "请选择链接dwg图中的风管边线图层");
								transaction.Commit();
								this.ShowMessage(dwgEntitiesSelection);
							}
							catch
							{
								bool flag4 = transaction.HasStarted();
								if (flag4)
								{
									transaction.RollBack();
								}
							}
							this.lstCurveInfo = new List<CurveInfo>();
							for (int i = 0; i < this.lstCurveInfoArc.Count; i++)
							{
								bool flag5 = !this.lstCurveInfoArc[i].ThisCurve.IsBound;
								if (flag5)
								{
									this.lstCurveInfoArc.RemoveAt(i);
									i--;
								}
								else
								{
									bool flag6 = this.lstCurveInfoArc[i].ThisCurve is Line;
									if (flag6)
									{
										this.lstCurveInfo.Add(this.lstCurveInfoArc[i]);
									}
								}
							}
						}
						catch (Exception ex)
						{
							continue;
						}
						bool flag7 = this.lstCurveInfoArc.Count > 0;
						if (flag7)
						{
							this.tmpCategory = this.lstCurveInfoArc[0].RevitLayer;
							this.elementId = this.lstCurveInfoArc[0].RevitLayer.Id;
							ductFastModelForm.pbxDuctLine.BackgroundImage = Resources.QuickModelGreen;
							ductFastModelForm.pbxDuctLine.BackgroundImageLayout = ImageLayout.Stretch;
						}
						this.ductRequest.LstAllCurve = this.ReturnCurves(this.lstCurveInfoArc);
						this.ductRequest.LstAllLine = this.ReturnCurves(this.lstCurveInfo);
						bool flag8 = this.IsOKButtonUsable(this.ductRequest, ductFastModelForm);
						if (flag8)
						{
							ductFastModelForm.EnableOkButton = true;
						}
					}
					else
					{
						bool flag9 = ductFastModelForm.DlgCloseType == CloseDuctDlgType.SelectFlange;
						if (flag9)
						{
							bool flag10 = this.tmpCategory != null;
							if (flag10)
							{
								this.ShowLayer(document, ref this.tmpCategory);
							}
							this.lstFlangeCurveInfo = new List<CurveInfo>();
							DwgEntitiesSelection dwgEntitiesSelection2 = new DwgEntitiesSelection(this.m_uiDoc);
							try
							{
								Transaction transaction2 = new Transaction(document);
								try
								{
									transaction2.Start("选择法兰");
									dwgEntitiesSelection2.TryPickSameLayerCurve(out this.lstFlangeCurveInfo, true, SelecteEntType.eLine | SelecteEntType.ePolyLine, "请选择链接dwg图中的管件法兰");
									transaction2.Commit();
									this.ShowMessage(dwgEntitiesSelection2);
								}
								catch
								{
									bool flag11 = transaction2.HasStarted();
									if (flag11)
									{
										transaction2.RollBack();
									}
								}
							}
							catch (Exception)
							{
								continue;
							}
							bool flag12 = this.lstFlangeCurveInfo.Count > 0;
							if (flag12)
							{
								this.tmpCategory = this.lstFlangeCurveInfo[0].RevitLayer;
								ductFastModelForm.pbxFlange.BackgroundImage = Resources.QuickModelGreen;
								ductFastModelForm.pbxFlange.BackgroundImageLayout = ImageLayout.Stretch;
							}
							for (int j = 0; j < this.lstFlangeCurveInfo.Count; j++)
							{
								bool flag13 = !this.lstFlangeCurveInfo[j].ThisCurve.IsBound;
								if (flag13)
								{
									this.lstFlangeCurveInfo.RemoveAt(j);
									j--;
								}
							}
							this.ductRequest.LstFlangeCurveInfos = new List<Curve>();
							this.ductRequest.LstFlangeCurveInfos.AddRange(this.ReturnCurves(this.lstFlangeCurveInfo));
							bool flag14 = this.IsOKButtonUsable(this.ductRequest, ductFastModelForm);
							if (flag14)
							{
								ductFastModelForm.EnableOkButton = true;
							}
						}
						else
						{
							bool flag15 = ductFastModelForm.DlgCloseType == CloseDuctDlgType.SelectFit;
							if (flag15)
							{
								bool flag16 = this.tmpCategory != null;
								if (flag16)
								{
									this.ShowLayer(document, ref this.tmpCategory);
								}
								List<BlockInfo> list2 = new List<BlockInfo>();
								DwgEntitiesSelection dwgEntitiesSelection3 = new DwgEntitiesSelection(this.m_uiDoc);
								try
								{
									Transaction transaction3 = new Transaction(document);
									try
									{
										transaction3.Start("拾取管件块");
										dwgEntitiesSelection3.TryPickSameLayerBlockRef<BlockInfo>(out list2, true, "请选择链接dwg文件中的管件");
										transaction3.Commit();
										this.ShowMessage(dwgEntitiesSelection3);
									}
									catch
									{
										bool flag17 = transaction3.HasStarted();
										if (flag17)
										{
											transaction3.RollBack();
										}
									}
								}
								catch (Exception)
								{
									continue;
								}
								bool flag18 = list2.Count > 0;
								if (flag18)
								{
									this.tmpCategory = list2[0].RevitLayer;
									ductFastModelForm.pbxFit.BackgroundImage = Resources.QuickModelGreen;
									ductFastModelForm.pbxFit.BackgroundImageLayout = ImageLayout.Stretch;
								}
								List<List<Curve>> list3 = new List<List<Curve>>();
								foreach (BlockInfo blockInfo in list2)
								{
									List<Curve> list4 = new List<Curve>();
									List<Curve> boundingBoxCurve = blockInfo.BoundingBoxCurve;
									foreach (Curve curve in boundingBoxCurve)
									{
										XYZ endPoint = curve.GetEndPoint(0);
										XYZ endPoint2 = curve.GetEndPoint(1);
										bool flag19 = curve is Line;
										if (flag19)
										{
											try
											{
												list4.Add(Line.CreateBound(new XYZ(endPoint.X, endPoint.Y, 0.0), new XYZ(endPoint2.X, endPoint2.Y, 0.0)));
											}
											catch (Exception)
											{
											}
										}
										else
										{
											bool flag20 = curve is Arc;
											if (flag20)
											{
												try
												{
													XYZ xyz = curve.Evaluate(0.5, true);
													list4.Add(Arc.Create(new XYZ(endPoint.X, endPoint.Y, 0.0), new XYZ(endPoint2.X, endPoint2.Y, 0.0), new XYZ(xyz.X, xyz.Y, 0.0)));
												}
												catch (Exception)
												{
												}
											}
										}
									}
									list3.Add(list4);
								}
								this.ductRequest.LstBlockInfos.AddRange(list3);
								bool flag21 = this.IsOKButtonUsable(this.ductRequest, ductFastModelForm);
								if (flag21)
								{
									ductFastModelForm.EnableOkButton = true;
								}
							}
							else
							{
								bool flag22 = ductFastModelForm.DlgCloseType == CloseDuctDlgType.SelectSizeText;
								if (flag22)
								{
									bool flag23 = this.tmpCategory != null;
									if (flag23)
									{
										this.ShowLayer(document, ref this.tmpCategory);
									}
									List<TextInfo> list5 = new List<TextInfo>();
									DwgEntitiesSelection dwgEntitiesSelection4 = new DwgEntitiesSelection(this.m_uiDoc);
									try
									{
										Transaction transaction4 = new Transaction(document);
										try
										{
											transaction4.Start("拾取文字");
											dwgEntitiesSelection4.TryPickSameLayerText(out list5, true, "拾取文字");
											transaction4.Commit();
											this.ShowMessage(dwgEntitiesSelection4);
										}
										catch
										{
											bool flag24 = transaction4.HasStarted();
											if (flag24)
											{
												transaction4.RollBack();
											}
										}
									}
									catch (Exception)
									{
										continue;
									}
									bool flag25 = list5.Count > 0;
									if (flag25)
									{
										this.tmpCategory = list5[0].RevitLayer;
										ductFastModelForm.pbxSize.BackgroundImage = Resources.QuickModelGreen;
										ductFastModelForm.pbxSize.BackgroundImageLayout = ImageLayout.Stretch;
									}
									foreach (TextInfo textInfo in list5)
									{
										DuctHeight ductHeight = new DuctHeight();
										ductHeight.TextInfo = textInfo;
										ductHeight.dDuctHeight = "0";
										this.ductRequest.LstDuctHeights.Add(ductHeight);
									}
									bool flag26 = this.IsOKButtonUsable(this.ductRequest, ductFastModelForm);
									if (flag26)
									{
										ductFastModelForm.EnableOkButton = true;
									}
								}
								else
								{
									bool flag27 = ductFastModelForm.DlgCloseType == CloseDuctDlgType.NextButton;
									if (flag27)
									{
										bool flag28 = this.tmpCategory != null;
										if (flag28)
										{
											this.ShowLayer(document, ref this.tmpCategory);
										}
										this.DoNextForm();
										break;
									}
									bool flag29 = ductFastModelForm.DlgCloseType == CloseDuctDlgType.SetButton;
									if (!flag29)
									{
										bool flag30 = this.tmpCategory != null;
										if (flag30)
										{
											this.ShowLayer(document, ref this.tmpCategory);
										}
										break;
									}
									bool flag31 = this.tmpCategory != null;
									if (flag31)
									{
										this.ShowLayer(document, ref this.tmpCategory);
									}
									DuctSetForm ductSetForm = new DuctSetForm();
									ductSetForm.ShowDialog(this.m_handleRevit);
									DuctFormData.m_dMaxDistance = ductSetForm.m_strHeight;
								}
							}
						}
					}
				}
				bool flag32 = dialogResult == DialogResult.Cancel;
				if (flag32)
				{
					this.m_bCancel = true;
				}
				else
				{
					double dMaxWidth = Common.MMToFeet(this.m_MaxDuctWidth);
					double dMinWidth = Common.MMToFeet(110.0);
					double dMinLen = Common.MMToFeet(100.0);
					this.ductRequest.LstDoubleParaleCurves = new List<DoubleParaleCurve>();
					List<DoubleParaleCurve> ductCurves = DoubleCurveManager.GetDuctCurves(this.ductRequest.LstAllLine, dMaxWidth, dMinWidth, dMinLen);
					List<DoubleParaleCurve> list6 = new List<DoubleParaleCurve>();
					this.ductRequest.LstInitDoubleParaleCurve.Clear();
					foreach (DoubleParaleCurve doubleParaleCurve in ductCurves)
					{
						bool flag33 = Math.Abs(doubleParaleCurve.FirstParalelCurve.Length - doubleParaleCurve.SecondParalelCurve.Length) < 0.06;
						if (flag33)
						{
							list6.Add(doubleParaleCurve);
							this.ductRequest.LstInitDoubleParaleCurve.Add(doubleParaleCurve);
						}
					}
					for (int k = 0; k < list6.Count; k++)
					{
						DoubleParaleCurve doubleParaleCurve2 = list6[k];
						Line lineOne = doubleParaleCurve2.FirstParalelCurve as Line;
						Line lineOne2 = doubleParaleCurve2.SecondParalelCurve as Line;
						for (int l = 0; l < list6.Count; l++)
						{
							bool flag34 = l == k;
							if (!flag34)
							{
								DoubleParaleCurve doubleParaleCurve3 = list6[l];
								Line lineTwo = doubleParaleCurve3.FirstParalelCurve as Line;
								Line lineTwo2 = doubleParaleCurve3.SecondParalelCurve as Line;
								Line line;
								Line line2;
								bool flag35 = (this.ParallelAndEqual(lineOne, lineTwo, out line) && this.ParallelAndEqual(lineOne2, lineTwo2, out line2)) || (this.ParallelAndEqual(lineOne2, lineTwo, out line) && this.ParallelAndEqual(lineOne, lineTwo2, out line2));
								if (flag35)
								{
									bool flag36 = l > k;
									if (flag36)
									{
										list6.RemoveAt(l);
										list6.RemoveAt(k);
									}
									else
									{
										list6.RemoveAt(k);
										list6.RemoveAt(l);
									}
									bool flag37 = k == 0;
									if (flag37)
									{
										k = 0;
									}
									else
									{
										k--;
									}
									DoubleParaleCurve doubleParaleCurve4 = new DoubleParaleCurve();
									doubleParaleCurve4.FirstParalelCurve = line;
									doubleParaleCurve4.SecondParalelCurve = line2;
									try
									{
										XYZ xyz2 = line.GetEndPoint(1) - line.GetEndPoint(0);
										XYZ xyz3 = line2.GetEndPoint(1) - line2.GetEndPoint(0);
										double num = 1.0;
										double num2 = xyz2.AngleTo(xyz3) * 180.0 / Math.PI;
										bool flag38 = num2 < num;
										if (flag38)
										{
											doubleParaleCurve4.LocationCurve = Line.CreateBound((line.GetEndPoint(0) + line2.GetEndPoint(0)) / 2.0, (line.GetEndPoint(1) + line2.GetEndPoint(1)) / 2.0);
										}
										else
										{
											doubleParaleCurve4.LocationCurve = Line.CreateBound((line.GetEndPoint(0) + line2.GetEndPoint(1)) / 2.0, (line.GetEndPoint(1) + line2.GetEndPoint(0)) / 2.0);
										}
										list6.Add(doubleParaleCurve4);
										break;
									}
									catch (Exception)
									{
									}
								}
							}
						}
					}
					foreach (DoubleParaleCurve item in list6)
					{
						this.ductRequest.LstDoubleParaleCurves.Add(item);
					}
					this.ductRequest.m_Doc = document;
					this.m_lstRequestes.Add(this.ductRequest);
					this.m_lstRequestes.Add(new DuctFitRequest());
				}
			}
		}

		private bool IsOKButtonUsable(DuctRequest ductRequest, DuctFastModelForm form)
		{
			bool flag = ductRequest.LstAllCurve.Count > 0 && ductRequest.LstFlangeCurveInfos.Count > 0 && form.radAppoint.Checked && !string.IsNullOrEmpty(form.cmbDuctHeight.Text);
			bool result;
			if (flag)
			{
				result = true;
			}
			else
			{
				bool flag2 = ductRequest.LstAllCurve.Count > 0 && ductRequest.LstFlangeCurveInfos.Count > 0 && form.radAuto.Checked && ductRequest.LstDuctHeights.Count > 0;
				if (flag2)
				{
					result = true;
				}
				else
				{
					bool flag3 = ductRequest.LstAllCurve.Count > 0 && ductRequest.LstBlockInfos.Count > 0 && form.radAppoint.Checked && !string.IsNullOrEmpty(form.cmbDuctHeight.Text);
					if (flag3)
					{
						result = true;
					}
					else
					{
						bool flag4 = ductRequest.LstAllCurve.Count > 0 && ductRequest.LstBlockInfos.Count > 0 && form.radAuto.Checked && ductRequest.LstDuctHeights.Count > 0;
						result = flag4;
					}
				}
			}
			return result;
		}

		private void ShowMessage(DwgEntitiesSelection dwgSelection)
		{
			bool flag = dwgSelection.Result > DwgEntitiesSelectionResult.eOK;
			if (flag)
			{
				bool flag2 = false;
				string resultInfo = DwgEntitiesSelectionCommon.GetResultInfo(dwgSelection.Result, out flag2);
				bool flag3 = !flag2;
				if (flag3)
				{
					YJKMessageBox.Show(resultInfo);
				}
			}
		}

		private bool ParallelAndEqual(Line lineOne, Line lineTwo, out Line lineNew)
		{
			XYZ endPoint = lineOne.GetEndPoint(0);
			XYZ endPoint2 = lineOne.GetEndPoint(1);
			XYZ endPoint3 = lineTwo.GetEndPoint(0);
			XYZ endPoint4 = lineTwo.GetEndPoint(1);
			lineNew = null;
			double num = 0.001;
			bool flag = YJKRGeometry.Geometry.IsParallel(lineOne.Direction, lineTwo.Direction);
			bool result;
			if (flag)
			{
				bool flag2 = endPoint.DistanceTo(endPoint3) < num;
				if (flag2)
				{
					lineNew = Line.CreateBound(endPoint2, endPoint4);
					result = true;
				}
				else
				{
					bool flag3 = endPoint.DistanceTo(endPoint4) < num;
					if (flag3)
					{
						lineNew = Line.CreateBound(endPoint2, endPoint3);
						result = true;
					}
					else
					{
						bool flag4 = endPoint2.DistanceTo(endPoint3) < num;
						if (flag4)
						{
							lineNew = Line.CreateBound(endPoint, endPoint4);
							result = true;
						}
						else
						{
							bool flag5 = endPoint2.DistanceTo(endPoint4) < num;
							if (flag5)
							{
								lineNew = Line.CreateBound(endPoint, endPoint3);
								result = true;
							}
							else
							{
								result = false;
							}
						}
					}
				}
			}
			else
			{
				result = false;
			}
			return result;
		}

		private void ShowLayer(Autodesk.Revit.DB.Document doc, ref Category layer)
		{
			Transaction transaction = new Transaction(doc);
			try
			{
				transaction.Start("恢复图层");
				doc.ActiveView.HYSetVisibility(layer, true);
				layer = null;
				transaction.Commit();
			}
			catch
			{
				bool flag = transaction.HasStarted();
				if (flag)
				{
					transaction.RollBack();
				}
			}
		}

		private List<Curve> ReturnCurves(List<CurveInfo> lstCurveInfo)
		{
			List<Curve> list = new List<Curve>();
			foreach (CurveInfo curveInfo in lstCurveInfo)
			{
				bool flag = curveInfo == null || curveInfo.ThisCurve == null;
				if (!flag)
				{
					Curve curve = curveInfo.ThisCurve;
					XYZ endPoint = curve.GetEndPoint(0);
					XYZ endPoint2 = curve.GetEndPoint(1);
					bool flag2 = curve is Line;
					if (flag2)
					{
						try
						{
							curve = Line.CreateBound(new XYZ(endPoint.X, endPoint.Y, 0.0), new XYZ(endPoint2.X, endPoint2.Y, 0.0));
							list.Add(curve);
						}
						catch (Exception ex)
						{
						}
					}
					else
					{
						bool flag3 = curve is Arc;
						if (flag3)
						{
							try
							{
								XYZ xyz = curve.Evaluate(0.5, true);
								curve = Arc.Create(new XYZ(endPoint.X, endPoint.Y, 0.0), new XYZ(endPoint2.X, endPoint2.Y, 0.0), new XYZ(xyz.X, xyz.Y, 0.0));
								list.Add(curve);
							}
							catch (Exception ex2)
							{
							}
						}
					}
				}
			}
			return list;
		}

		private void DoNextForm()
		{
			NextDuctFastmodelForm nextDuctFastmodelForm = new NextDuctFastmodelForm(this.m_uiDoc);
			DialogResult dialogResult = nextDuctFastmodelForm.ShowDialog(this.m_handleRevit);
			bool flag = dialogResult == DialogResult.OK;
			if (flag)
			{
				bool flag2 = nextDuctFastmodelForm.DlgCloseType == CloseDuctDlgType.AreaFastModel;
				if (flag2)
				{
					List<CurveInfo> list = new List<CurveInfo>();
					List<CurveInfo> list2 = new List<CurveInfo>();
					List<CurveInfo> list3 = new List<CurveInfo>();
					try
					{
						List<CurveInfo> list4 = new List<CurveInfo>();
						list4.AddRange(this.lstCurveInfoArc);
						list4.AddRange(this.lstFlangeCurveInfo);
						DwgEntitiesSelection dwgEntitiesSelection = new DwgEntitiesSelection(this.m_uiDoc);
						dwgEntitiesSelection.TryGetEntitesInPickBox<CurveInfo>(out list, list4, new DelegateInRange<CurveInfo>(this.CheckCurveIsInRange), "请框选需转换的范围");
						string strEdgeLayer = string.Empty;
						bool flag3 = !this.lstCurveInfoArc.IsEmpty<CurveInfo>();
						if (flag3)
						{
							strEdgeLayer = this.lstCurveInfoArc[0].UseLayerName;
						}
						string strFlangeLayer = string.Empty;
						bool flag4 = !this.lstFlangeCurveInfo.IsEmpty<CurveInfo>();
						if (flag4)
						{
							strFlangeLayer = this.lstFlangeCurveInfo[0].UseLayerName;
						}
						list2 = list.FindAll((CurveInfo item) => item.UseLayerName == strEdgeLayer);
						list3 = list.FindAll((CurveInfo item) => item.UseLayerName == strFlangeLayer);
					}
					catch (Exception)
					{
					}
					List<Curve> list5 = new List<Curve>();
					list5 = this.ReturnCurves(list2);
					this.ductRequest.LstAllCurve = list5;
					List<Curve> list6 = new List<Curve>();
					foreach (Curve curve in list5)
					{
						bool flag5 = curve is Line;
						if (flag5)
						{
							list6.Add(curve);
						}
					}
					this.ductRequest.LstAllLine = list6;
					this.ductRequest.LstFlangeCurveInfos = this.ReturnCurves(list3);
				}
				else
				{
					bool flag6 = nextDuctFastmodelForm.DlgCloseType == CloseDuctDlgType.LevelFastModel;
					if (!flag6)
					{
						bool flag7 = nextDuctFastmodelForm.DlgCloseType == CloseDuctDlgType.SystemFastModel;
						if (flag7)
						{
							try
							{
								CurveInfo item2 = null;
								List<ElementId> list7 = new List<ElementId>();
								bool flag8 = this.lstCurveInfo.Count > 0;
								if (flag8)
								{
									list7.Add(this.elementId);
								}
								DwgEntitiesSelection dwgEntitiesSelection2 = new DwgEntitiesSelection(this.m_uiDoc);
								dwgEntitiesSelection2.TryPickOneCurveLimitLayer(out item2, list7, SelecteEntType.eLine | SelecteEntType.ePolyLine, "请拾取系统中的某一根线！");
								List<Curve> list8 = this.ReturnCurves(new List<CurveInfo>
								{
									item2
								});
								this.ductRequest.CurveBySys = list8[0];
							}
							catch (Exception)
							{
							}
						}
					}
				}
			}
			else
			{
				bool flag9 = dialogResult == DialogResult.Cancel;
				if (flag9)
				{
					this.m_bCancel = true;
				}
			}
		}

		public bool CheckCurveIsInRange(CurveInfo curveInfo, PickedBox pickBox)
		{
			bool flag = curveInfo == null || pickBox == null;
			bool result;
			if (flag)
			{
				result = false;
			}
			else
			{
				XYZ endPoint = curveInfo.ThisCurve.GetEndPoint(0);
				XYZ endPoint2 = curveInfo.ThisCurve.GetEndPoint(1);
				XYZ xyz = new XYZ(Math.Min(pickBox.Min.X, pickBox.Max.X), Math.Min(pickBox.Min.Y, pickBox.Max.Y), 0.0);
				XYZ xyz2 = new XYZ(Math.Max(pickBox.Min.X, pickBox.Max.X), Math.Max(pickBox.Min.Y, pickBox.Max.Y), 0.0);
				bool flag2 = endPoint.X > xyz.X && endPoint.Y > xyz.Y && endPoint.X < xyz2.X && endPoint.Y < xyz2.Y;
				if (flag2)
				{
					result = true;
				}
				else
				{
					bool flag3 = endPoint2.X > xyz.X && endPoint2.Y > xyz.Y && endPoint2.X < xyz2.X && endPoint2.Y < xyz2.Y;
					result = flag3;
				}
			}
			return result;
		}

		public override void CloseFrom()
		{
			throw new NotImplementedException();
		}

		public override List<InputRequest> GetAllInputRequest()
		{
			return this.m_lstRequestes;
		}

		private List<InputRequest> m_lstRequestes = new List<InputRequest>();

		private List<CurveInfo> lstCurveInfo = new List<CurveInfo>();

		private List<CurveInfo> lstCurveInfoArc = new List<CurveInfo>();

		private List<CurveInfo> lstFlangeCurveInfo = new List<CurveInfo>();

		private ElementId elementId = null;

		private Category tmpCategory = null;

		private UIDocument m_uiDoc;

		private DuctRequest ductRequest = new DuctRequest();

		private double m_MaxDuctWidth = 4000.0;
	}
}
